//
//  CircleCommentCell.m
//  GolfFriend
//
//  Created by vescky on 14-2-6.
//  Copyright (c) 2014年 vescky.org. All rights reserved.
//

#import "CircleCommentCell.h"
#import "UIImageView+MJWebCache.h"
#import "DateUtility.h"
#import <QuartzCore/QuartzCore.h>

#define Comment_Font_Size 15.0

@interface CircleCommentCell (){
    UILabel *labelContent;
}

@end

@implementation CircleCommentCell


- (void)setDataInfo:(NSDictionary*)_dict {
    NSDate *cDate = getDateFromString(@"yyyy-MM-dd HH:mm:ss", [_dict objectForKey:@"time"]);
    [labelTime setText:getWeiboDisplayTimeFromDate(cDate)];
    [labelUserName setText:[_dict objectForKey:@"nickName"]];//[NSString stringWithFormat:@"%@  发表了评论",[_dict objectForKey:@"nickName"]]];
    NSString *avatarString = [_dict objectForKey:@"avatar"];
    if ([avatarString isKindOfClass:NSClassFromString(@"NSString")]) {
        [imgvAvatar setImageURLStr:avatarString placeholder:Default_Avatar];
    }
    imgvAvatar.layer.cornerRadius = imgvAvatar.frame.size.width / 2.0;
    
    CGRect contentFrame = CGRectMake(70, 40, 230, 25);
    labelContent = [[UILabel alloc] initWithFrame:contentFrame];
    NSString *contentString = [_dict objectForKey:@"content"];
    CGSize cSize = [contentString sizeWithFont:[UIFont systemFontOfSize:Comment_Font_Size] constrainedToSize:CGSizeMake(contentFrame.size.width,2000) lineBreakMode:0];
    contentFrame.size.height = cSize.height > contentFrame.size.height ? cSize.height : contentFrame.size.height;
    labelContent.numberOfLines= 0;
    labelContent.font = [UIFont systemFontOfSize:Comment_Font_Size];
    labelContent.text = contentString;
    labelContent.frame = contentFrame;
    
    [self.contentView addSubview:labelContent];
    
    CGRect rect = self.frame;
    rect.size.height = contentFrame.origin.y + contentFrame.size.height + 10;
    [self setFrame:rect];
}

- (float)getContentHeight:(NSDictionary*)_dict {
    [self setDataInfo:_dict];
    return self.frame.size.height;
}


@end
